
import * as BaseApi from './BaseApi.js';

import * as Config from './Config.js';


//上传图片
export const upLoadPicture = (form) => {
    
       return BaseApi.requestBody(Config.g_biz_url, '/fileupload',  form, {
        method: 'post',
        headers: { 'Content-Type': 'multipart/form-data' }
    })
           .then(res => res)
   }


//修改商户信息
export const updateMerchantInfo = (model) => {
    
       return BaseApi.requestForm(Config.g_biz_url, '/supplier/update', model)
           .then(res => res)
   }

//获取商户信息
export const getMerchantInfo = (self) => {
 
    return BaseApi.requestForm(Config.g_biz_url, '/supplier/info/bysupplier', {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    })
        .then(res => res)
}

//登录
export const doLogin = (model) => {
    return BaseApi.requestForm(Config.g_biz_url, '/auth/merchant/login', model)
        .then(res => res)
}


//自定义属性取消匹配车型
export const cancelMaintainLinkCar = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/car/linkdelete', model)
        .then(res => res)
}



//自定义属性匹配车型
export const maintainLinkCar = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/car/linkadd', model)
        .then(res => res)
}


//修改自定义属性
export const editInfoEditForm = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/update', model)
        .then(res => res)
}
//新增自定义属性
export const addInfoEditForm = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/add', model)
        .then(res => res)
}


//属性ID查询绑定的所有车型
export const getCarIdListBymaintainId = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/car/linklist', model)
        .then(res => res)
}
//初始化筛选字段
export const initFilterList = () => {
    return BaseApi.requestForm(Config.g_service_url, '/screeninit')
        .then(res => res)
}


//分组详情
export const MaintainDatil = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/info/list', model)
        .then(res => res)
}

//修改分组
export const MaintainUpdate = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/group/update', model)
        .then(res => res)
}


//添加分组
export const MaintainAdd = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/group/add', model)
        .then(res => res)
}
//查询分组列表
export const getMaintainList = (self,model) => {

    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/maintain/group/list', model)
        .then(res => res)
}
//获取品牌列表
export const getBrandList = () => {

    return BaseApi.requestForm(Config.g_service_url, '/brandlist')
        .then(res => res)
}
//通过BrandID获取车系列表
export const getSeriesList = (brandId) => {
    return BaseApi.requestForm(Config.g_service_url, `/serieslist?brandId=${brandId}`)
        .then(res => res)
}
//通过品牌、车系ID 获取年份列表
export const getYearsList = (brandId, seriesId) => {
    return BaseApi.requestForm(Config.g_service_url, `/bsm?brandId=${brandId}&seriesId=${seriesId}`)
        .then(res => res)
}



//订单
export const getOrderList = (self,model) => {
    Object.assign(model, {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    });
    return BaseApi.requestForm(Config.g_biz_url, '/order/manager/queryorder', model)
        .then(res => res)
}




//会员列表

export const getUserList = (self) => {
    return BaseApi.requestForm(Config.g_biz_url, '/user/manager/query', {
        token: self.$store.getters.getToken,
        merchantId: self.$store.getters.getMerchantId
    })
        .then(res => res)
}